package controller;

import bean.UserInfo;
import service.IUserInfoService;
import service.impl.UserInfoServiceImpl;

import java.util.List;

public class UserInfoController {
    IUserInfoService userInfoService=new UserInfoServiceImpl();

    public List<UserInfo> queryUserInfo() throws Exception{

        return userInfoService.queryUserInfo();
    }


    public boolean insertUserInfo(UserInfo userInfo) throws  Exception{

        boolean flag = userInfoService.insertUserInfo(userInfo);

        if(flag){
            System.out.println("插入成功");
        }
        else{
            System.out.println("插入失败");
        }

        return flag;
    }

    public boolean updateUserInfo(UserInfo userInfo) throws Exception{

        boolean flag = userInfoService.updateUserInfo(userInfo);

        if(flag){
            System.out.println("修改成功");
        }
        else{
            System.out.println("修改失败");
        }

        return flag;

    }

    public boolean deleteUserInfo(int id) throws Exception{
        boolean flag = userInfoService.deleteUserInfo(id);

        if(flag){
            System.out.println("删除成功");
        }
        else{
            System.out.println("删除失败");
        }
        return flag;
    }
}
